Skip to content

test(insurance): drive the recommendation comparison through the real Archera client - #1064

Merged
cristim merged 3 commits into
feat/799-archera-recommendation-routefrom
test/799-archera-recommendation-contract
Oct 17, 2026
Merged

cristim merged 3 commits into
feat/799-archera-recommendation-routefrom
test/799-archera-recommendation-contract

Conversation

@cristim

@cristim cristim commented Oct 17, 2026

Copy link
Copy Markdown
Member

What

A contract test that drives Router GET /api/insurance/comparison?recommendation_id=... through the real archera.Provider and real insurance.Client over an intercepted http.RoundTripper, down to the decoded recommendation DTO.

Why

The earlier PRs in the stack test the handler with a fake client. This is the only test that exercises the real paginator, URL building, header and query encoding on the production read path.

Asserts

  • Public URL paths, the x-api-key header, LineItems pagination (the matching item is on page 2).
  • Comparison query: line_item_ids equals the selected ID and payment_options is all three (read as multisets).
  • A partial_upfront recommendation matches.
  • A late page-2 failure gives a fixed 502 with no partial result and no comparison call.
  • A missing comparison row, and a source-account case mismatch, give unavailable.
  • Null currency and null delta; no unrelated row, account, plan or rollup figures in the output.
  • A changed row after the fetch gives 409.
  • Unauthorized, scoped, duplicate-store and missing-row paths make zero secret and vendor calls.

Evidence

Synthetic vendor transport through the actual production read path, shaped after the Archera Public OpenAPI (including the X-Pagination header). It is not a live Archera org. Mutation probes (scratch, reverted) each failed a named assertion in this file: dropping the post-fetch reread, swallowing the LineItems error, dropping payment_options. GOWORK=off go test -race ./internal/api/ -run Insurance, go vet ./... and gofmt are clean.

Refs #799

Stack: this PR targets feat/799-archera-recommendation-route (#1061), which stacks on #1063, #1058, #1056 and #1054.

🤖 Generated with Claude Code

… Archera client

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration
  • Configuration used: Repository: LeanerCloud/cloud-commitments-platform/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Essentials
  • Run ID: 3108400b-6da6-4d8d-af54-e01c6d03dce5

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

@cristim cristim added effort/l Weeks priority/p3 Polish / idea / may never ship severity/low Minor harm urgency/eventually No deadline impact/few Limited audience type/feat New capability triaged Item has been triaged labels Oct 17, 2026
@cristim

cristim commented Oct 17, 2026

Copy link
Copy Markdown
Member Author

Independent review verdict: BLOCKING at 2f6dc2c (lint only; the test itself is sound)

Reviewer: fresh Claude agent (Sonnet 5.5, high effort), not the author. Coordinator: claude-cc-reviewer.

Blocking (gate): golangci-lint v2.10.1 with --new-from-rev=489ca273 reports one issue: misspell at internal/api/handler_insurance_recommendation_contract_test.go:22, "organisation" should be "organization". CI will catch this once the PR is retargeted to main.

What was verified:

  • Real code path. The test builds archera.NewProvider(..., &http.Client{Transport: vendor}) (:117), which in turn builds the real insurance.NewClient (provider.go:119-150). It drives the real Router, then FetchRecommendationComparison, then the real LineItems and Comparison.
  • No network access. The transport is injected. Unexpected hosts and paths are fatal, and the key is synthetic.
  • Assertions catch regressions. Each mutation probe was reverted afterwards:
    • dropping x-api-key fails at :72;
    • stopping after page 1 fails at :129 and :161;
    • sending the wrong line_item_ids fails at :143;
    • dropping a payment option fails at :144;
    • skipping the reread fails at :146 and :192.
  • No flakiness. -race -count=3 passes, with no wall-clock dependence, goroutines or global mutation.

Non-blocking: the fake vendor never asserts order_by=id (line_items_client.go:123).

Next: fix the spelling in a new commit. Merge after #1058, #1063 and #1061 merge and this PR's full CI is green.

cristim and others added 2 commits October 17, 2026 20:53
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… item on demand (#1070)

Adds an explicit read-only row action that fetches
GET /api/insurance/comparison?recommendation_id=<id> and renders native
vendor figures as text, with fixed messages per error status.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
@cristim
cristim merged commit 80122aa into feat/799-archera-recommendation-route Oct 17, 2026
1 check passed
cristim added a commit that referenced this pull request Oct 17, 2026
…ine item (#1061)

* feat(insurance): compare one stored recommendation with its Archera line item

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* test(insurance): drive the recommendation comparison through the real Archera client (#1064)

* test(insurance): drive the recommendation comparison through the real Archera client

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* test(insurance): fix spelling flagged by misspell

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* feat(recommendations): compare a recommendation with its Archera line item on demand (#1070)

Adds an explicit read-only row action that fetches
GET /api/insurance/comparison?recommendation_id=<id> and renders native
vendor figures as text, with fixed messages per error status.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

effort/l Weeks impact/few Limited audience priority/p3 Polish / idea / may never ship severity/low Minor harm triaged Item has been triaged type/feat New capability urgency/eventually No deadline

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant